package com.gxa.saas.portal.service.impl;

import com.gxa.saas.core.vo.GoodsVo;
import com.gxa.saas.portal.mapper.GbGoodsMapper;
import com.gxa.saas.portal.service.GBGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: pengxtao
 * @Date: 2022/7/27下午4:34
 */
@Service
public class GBGoodsServiceImpl implements GBGoodsService {
    @Autowired
    private GbGoodsMapper gbGoodsMapper;

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    private static final String HOTCAKES = "hot_cakes";

    @Override
    public Boolean HotCommodity(Integer id) {
        List<GoodsVo> queryrx = gbGoodsMapper.queryrx(id);
        GoodsVo goodsVos = new GoodsVo();
        for (GoodsVo goodsVo : queryrx) {
            goodsVos=goodsVo;
        }
        BoundValueOperations<String, Object> boundValueOperations = redisTemplate.boundValueOps(HOTCAKES + goodsVos.getPrId());
        boundValueOperations.set(goodsVos);
        return queryrx.size()>0;
    }
}
